import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [{
    path: '/login',
    name: 'login',
    component: () => import('@/components/Login.vue')
  },

  {
    path: '/',
    component: () => import('@/components/Login.vue'),
    redirect: '/login',
  },
  {
    path: '/dashboard',
    component: () => import('../views/Dashboard.vue'),
  },
  {
    path: '/editPass',
    component: () => import('../views/EditPass.vue'),
  },
  //权限管理
  {
    path: '/permissions',
    component: () => import('../views/permissions/Index.vue'),
    redirect: '/permissions/role',
    children: [{
        path: 'role',
        name: '角色管理',
        component: () => import("../views/permissions/Role.vue"),
      },
      {
        path: 'user',
        name: '用户管理',
        component: () => import("../views/permissions/User.vue"),
      }
    ]
  },
  //协会动态
  {
    path: '/dynamic',
    component: () => import('../views/dynamic/Index.vue'),
    redirect: '/dynamic/construction',
    children: [{
        path: 'construction',
        name: '协会党建',
        component: () => import("../views/dynamic/Construction.vue"),
      },
      {
        path: 'association',
        name: '协会资讯',
        component: () => import("../views/dynamic/Association.vue"),
      },
      {
        path: 'branch',
        name: '分会资讯',
        component: () => import("../views/dynamic/Branch.vue"),
      },
      {
        path: 'vip',
        name: '会员资讯',
        component: () => import("../views/dynamic/Vip.vue"),
      },
      {
        path: 'activity',
        component: () => import('../views/dynamic/Activity.vue')
      },
      {
        path: 'live',
        component: () => import('../views/dynamic/Live.vue')
      },
    ]
  },

  //关于我们
  {
    path: '/about',
    component: () => import('../views/about/Index.vue'),
    redirect: '/about/introduce',
    children: [{
        path: 'introduce',
        name: '关于我们',
        component: () => import("../views/about/Introduce.vue"),
      },
      {
        path: 'vipList',
        name: '会员名录',
        component: () => import("../views/about/VipList.vue"),
      },
    ]
  },
  //背景设置
  {
    path: '/bgcSet',
    component: () => import('../views/bgcSet/Index.vue'),
    redirect: '/bgcSet/carousel',
    children: [{
        path: 'carousel',
        name: '首页轮播图',
        component: () => import("../views/bgcSet/Carousel.vue"),
      },
      {
        path: 'other',
        name: '协会资讯',
        component: () => import("../views/bgcSet/Other.vue"),
      },
    ]
  },
  // 协会服务
  {
    path: '/service',
    component: () => import('../views/service/Index.vue'),
    redirect: 'service/explain',
    children: [{
        path: 'capital',
        component: () => import("../views/service/Capital.vue"),
      },
      {
        path: 'energizeService',
        component: () => import("../views/service/EnergizeService.vue"),
      },
      {
        path: 'explain',
        component: () => import("../views/service/Explain.vue"),
      },
      {
        path: 'market',
        component: () => import("../views/service/Market.vue"),
      },
      {
        path: 'project',
        component: () => import("../views/service/Project.vue"),
      },
      {
        path: 'property',
        component: () => import("../views/service/Property.vue"),
      },

    ]
  },
  {
    path: '/apply',
    component: () => import('../views/apply/Index.vue'),
    redirect: 'apply/financial',
    children: [{
        path: 'financial',
        component: () => import("../views/apply/Financial.vue"),
      },
      {
        path: 'energize',
        component: () => import("../views/apply/Energize.vue"),
      },
      {
        path: 'attract',
        component: () => import("../views/apply/Attract.vue"),
      },
    ]
  },
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router